package org.plex.searchfilter.imp;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import org.plex.search.SortOrder;
import org.plex.search.imp.SortOrderImp;
import org.plex.searchfilter.DateFilter;
import org.plex.searchfilter.StatusFilter;
import org.plex.searchfilter.TaskFilter;

public class TaskFilterImp implements TaskFilter
{
	
	private com.adobe.idp.taskmanager.dsc.client.query.TaskFilter taskFilter;
	
	public TaskFilterImp(com.adobe.idp.taskmanager.dsc.client.query.TaskFilter taskFilter)throws NullPointerException
	{
	   if(null==taskFilter)
	   {
		   throw new NullPointerException();
	   }
	   this.taskFilter=taskFilter;
	}

	public void claimableTasks(boolean isClaimable)
	{
	     taskFilter.claimableTasks(isClaimable);
	}

	@SuppressWarnings("unchecked")
	public List<Long> getGroupQueueIdList()
	{
		// TODO Auto-generated method stub
		List<Long> list=taskFilter.getGroupQueueIdList();
		List<Long> groupQueeuList=new ArrayList<Long>((List<Long>)list);
		return groupQueeuList;
	}

	@SuppressWarnings("unchecked")
	public List<Long> getQueueIdList()
	{
		// TODO Auto-generated method stub
		List<Long> list=new ArrayList<Long>(taskFilter.getQueueIdList());
		return list;
	}

	public List<SortOrder> getSortList()
	{
		// TODO Auto-generated method stub
		List list=taskFilter.getSortList();
		List<SortOrder> sortOrderList=new ArrayList<SortOrder>();
		Iterator iterator=list.iterator();
		while(iterator.hasNext())
		{
			com.adobe.idp.taskmanager.dsc.client.query.SortOrder sortOrder=(com.adobe.idp.taskmanager.dsc.client.query.SortOrder)iterator.next();
			sortOrderList.add(new SortOrderImp(sortOrder));
		}
		return sortOrderList;
	}

	public SortOrder getSortOrder()
	{
		// TODO Auto-generated method stub
		
		return new SortOrderImp(taskFilter.getSort());
	}

	@SuppressWarnings("unchecked")
	public List<String> getUserIdList()
	{
		// TODO Auto-generated method stub
		List list=taskFilter.getUserIdList();
		List<String> stringList=new ArrayList<String>(list);
		return stringList;
	}

	public boolean isClaimable()
	{
		// TODO Auto-generated method stub
		return taskFilter.isClaimable();
	}

	public DateFilter newDateFilter(String dateSting)
	{

		return new DateFilterImp(taskFilter.newDateFilter(dateSting));
	}

	public SortOrder newSortOrder()
	{
		
		return new SortOrderImp(taskFilter.newSortOrder());
	}

	public StatusFilter newStatusFileFilter()
	{

		return new StatusFilterImp(taskFilter.newStatusFilter());
	}

	public void setClaimable(boolean isClaimable)
	{
	  this.taskFilter.setClaimable(isClaimable);
	}

	public void setDateFilter(DateFilter dateFilter)
	{
		DateFilterImp imp=(DateFilterImp)dateFilter;
		this.taskFilter.setDateFilter(imp.getDateFilter());

	}

	public void setGroupQueueId(long groupQueueId)
	{
		this.taskFilter.setGroupQueueId(groupQueueId);

	}

	public void setGroupQueueIdList(List<Long> groupQueueIdList)
	{
		this.taskFilter.setGroupQueueIdList(groupQueueIdList);

	}

	public void setMaxRows(int maxRows)
	{
       this.taskFilter.setMaxRows(maxRows);
	}

	public void setOffset(int offset)
	{
		this.taskFilter.setOffset(offset);
	}

	public void setQueueId(long queueId)
	{
        this.taskFilter.setQueueId(queueId);
	}

	public void setQueueIdList(List<Long> queueIdlist)
	{
	this.taskFilter.setQueueIdList(queueIdlist);

	}

	public void setSortList(List<SortOrder> sortOrder)
	{
		List list=new ArrayList();
		Iterator<SortOrder> iterator=sortOrder.iterator();
		while(iterator.hasNext())
		{
			SortOrderImp imp=(SortOrderImp)iterator.next();
			list.add(imp.getSortOrder());
		}
		this.taskFilter.setSortList(list);

	}

	public void setSortOrder(SortOrder sortOrder)
	{
		SortOrderImp imp=(SortOrderImp)sortOrder;
		this.taskFilter.setSort(imp.getSortOrder());

	}

	public void setStatusFiltering(StatusFilter statusFilter)
	{
		StatusFilterImp imp=(StatusFilterImp)statusFilter;
		this.taskFilter.setStatusFiltering(imp.getStatusFilter());

	}

	public void setTaskId(long taskId)
	{
	  this.taskFilter.setTaskId(taskId);
	}

	public void setUserId(String userID)
	{
		this.taskFilter.setUserId(userID);
	}

	public void setUserIdList(List<String> userIdList)
	{
		this.taskFilter.setUserIdList(userIdList);

	}

	public void showHiddenTask(boolean showHiddenTask)
	{
		this.taskFilter.showHiddenTask(true);

	}

	public void setTaskFilter(com.adobe.idp.taskmanager.dsc.client.query.TaskFilter taskFilter)
	{
		this.taskFilter = taskFilter;
	}

	public com.adobe.idp.taskmanager.dsc.client.query.TaskFilter getTaskFilter()
	{
		return taskFilter;
	}

}
